add test case for enableremote changing encryption
authorJoey Hess <joeyh@joeyh.name>
Thu, 21 Aug 2025 20:21:12 +0000 (16:21 -0400)
committerJoey Hess <joeyh@joeyh.name>
Thu, 21 Aug 2025 20:21:47 +0000 (16:21 -0400)
As fixed in 6b63fb7ea29f39b0fe7632dae6951c589115ee37

Sponsored-by: Brock Spratlen
Test.hs

diff --git a/Test.hs b/Test.hs
index 5240d3497d3ee7bd785a7905cb014593c9452ca2..2fb6d6a03b3f5c706445aa365a6f3ab262fe5826 100644 (file)
--- a/Test.hs
+++ b/Test.hs
@@ -370,6 +370,7 @@ repoTests note numparts = map mk $ sep
        , testCase "add subdirs" test_add_subdirs
        , testCase "addurl" test_addurl
        , testCase "repair" test_repair
+       , testCase "enableremote encryption changes" test_enableremote_encryption_changes
        ]
   where
        mk l = testGroup groupname (initTests : map adddep l)
@@ -2186,3 +2187,26 @@ test_repair :: Assertion
 test_repair = intmpclonerepo $
        -- Simply running repair used to fail on Windows.
        git_annex "repair" [] "repair"
+
+test_enableremote_encryption_changes :: Assertion
+test_enableremote_encryption_changes = intmpclonerepo $ do
+       createDirectory (literalOsPath "dir")
+       let dirparam="directory=dir"
+       git_annex "initremote" ["foo", "type=directory", "encryption=none", dirparam] 
+               "initremote"
+       git_annex_shouldfail "enableremote" ["foo", "encryption=shared", dirparam]
+               "enableremote adding new encryption"
+       git_annex "initremote" ["bar", "type=directory", "encryption=shared", dirparam] 
+               "initremote"
+       git_annex "enableremote" ["bar", "encryption=shared", dirparam] 
+               "enableremote with same encryption"
+       git_annex_shouldfail "enableremote" ["bar", "encryption=none", dirparam]
+               "enableremote disabling encryption"
+       git_annex_shouldfail "enableremote" ["bar", "onlyencryptcreds=yes", dirparam]
+               "enableremote with onlyencryptcreds"
+       git_annex "initremote" ["baz", "type=directory", "encryption=shared", "onlyencryptcreds=yes", dirparam]
+               "initremote"
+       git_annex_shouldfail "enableremote" ["baz", "onlyencryptcreds=no", dirparam]
+               "enableremote disabling onlyencryptcreds"
+       git_annex "enableremote" ["baz", "onlyencryptcreds=yes", dirparam]
+               "enableremote enabling already enabled onlyencryptcreds"